﻿using Microsoft.EntityFrameworkCore.Migrations;
using System;
using System.Collections.Generic;

namespace FwProject.Migrations
{
    public partial class ini201805 : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.AddColumn<int>(
                name: "EmployeeType",
                table: "AbpUsers",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<string>(
                name: "Face",
                table: "AbpUsers",
                nullable: true);

            migrationBuilder.AddColumn<Guid>(
                name: "FactoryinfoId",
                table: "AbpUsers",
                nullable: false,
                defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));

            migrationBuilder.AddColumn<string>(
                name: "Mobile",
                table: "AbpUsers",
                nullable: false,
                defaultValue: "");

            migrationBuilder.AddColumn<string>(
                name: "NowAddress",
                table: "AbpUsers",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "OpenId_Code",
                table: "AbpUsers",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "OpenId_Public",
                table: "AbpUsers",
                nullable: true);

            migrationBuilder.AddColumn<string>(
                name: "Unionid",
                table: "AbpUsers",
                nullable: true);

            migrationBuilder.CreateTable(
                name: "CarInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CarOld = table.Column<DateTime>(nullable: false),
                    CarType = table.Column<int>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    EmployeeCarUserId = table.Column<long>(nullable: false),
                    Insurance = table.Column<bool>(nullable: false),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    PlatesNumber = table.Column<string>(nullable: false),
                    ShoppingTon = table.Column<double>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_CarInfo", x => x.Id);
                    table.ForeignKey(
                        name: "FK_CarInfo_AbpUsers_EmployeeCarUserId",
                        column: x => x.EmployeeCarUserId,
                        principalTable: "AbpUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "FactoryNameInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    FactoryName = table.Column<string>(maxLength: 200, nullable: false),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_FactoryNameInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "RestaurantInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Character = table.Column<string>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    EmployeeDriverid = table.Column<long>(nullable: false),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    RestaurantAddress = table.Column<string>(maxLength: 200, nullable: false),
                    RestaurantName = table.Column<string>(maxLength: 200, nullable: false),
                    Thump = table.Column<string>(nullable: true),
                    latitude = table.Column<string>(maxLength: 200, nullable: false),
                    longitude = table.Column<string>(maxLength: 200, nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RestaurantInfo", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RestaurantInfo_AbpUsers_EmployeeDriverid",
                        column: x => x.EmployeeDriverid,
                        principalTable: "AbpUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "RestaurantUserInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    EmployeeRestaurantId = table.Column<long>(nullable: false),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    RestaurantInfoId = table.Column<Guid>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RestaurantUserInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "TypeNumberInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    AttributeFlag = table.Column<int>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    ModuleFlag = table.Column<int>(nullable: false),
                    Name = table.Column<string>(maxLength: 200, nullable: false),
                    OrderList = table.Column<int>(nullable: false),
                    Readme = table.Column<string>(maxLength: 200, nullable: true),
                    Unit = table.Column<int>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TypeNumberInfo", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "LoadCar",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CarInfoId = table.Column<Guid>(nullable: true),
                    CarStatus = table.Column<int>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LoadCar", x => x.Id);
                    table.ForeignKey(
                        name: "FK_LoadCar_CarInfo_CarInfoId",
                        column: x => x.CarInfoId,
                        principalTable: "CarInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "SettlementInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Actualprice = table.Column<decimal>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    Discountprice = table.Column<decimal>(nullable: false),
                    EmployeeDriverid = table.Column<long>(nullable: false),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    Restaurantid = table.Column<Guid>(nullable: true),
                    Totalprice = table.Column<decimal>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SettlementInfo", x => x.Id);
                    table.ForeignKey(
                        name: "FK_SettlementInfo_AbpUsers_EmployeeDriverid",
                        column: x => x.EmployeeDriverid,
                        principalTable: "AbpUsers",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_SettlementInfo_RestaurantInfo_Restaurantid",
                        column: x => x.Restaurantid,
                        principalTable: "RestaurantInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "RestaurantTypenNumberInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    Price = table.Column<decimal>(nullable: false),
                    Restaurantid = table.Column<Guid>(nullable: true),
                    TypeNumberId = table.Column<Guid>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RestaurantTypenNumberInfo", x => x.Id);
                    table.ForeignKey(
                        name: "FK_RestaurantTypenNumberInfo_RestaurantInfo_Restaurantid",
                        column: x => x.Restaurantid,
                        principalTable: "RestaurantInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_RestaurantTypenNumberInfo_TypeNumberInfo_TypeNumberId",
                        column: x => x.TypeNumberId,
                        principalTable: "TypeNumberInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "DistributionInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Carinfoid = table.Column<Guid>(nullable: true),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    LoadCarId = table.Column<Guid>(nullable: true),
                    Pricestatus = table.Column<int>(nullable: false),
                    Restaurantid = table.Column<Guid>(nullable: true),
                    SettlementId = table.Column<Guid>(nullable: true),
                    TotalPrice = table.Column<decimal>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DistributionInfo", x => x.Id);
                    table.ForeignKey(
                        name: "FK_DistributionInfo_CarInfo_Carinfoid",
                        column: x => x.Carinfoid,
                        principalTable: "CarInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_DistributionInfo_LoadCar_LoadCarId",
                        column: x => x.LoadCarId,
                        principalTable: "LoadCar",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_DistributionInfo_RestaurantInfo_Restaurantid",
                        column: x => x.Restaurantid,
                        principalTable: "RestaurantInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "LoadingCarInfo",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Countproduct = table.Column<int>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    LoadCarId = table.Column<Guid>(nullable: true),
                    TypeNumberInfoId = table.Column<Guid>(nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_LoadingCarInfo", x => x.Id);
                    table.ForeignKey(
                        name: "FK_LoadingCarInfo_LoadCar_LoadCarId",
                        column: x => x.LoadCarId,
                        principalTable: "LoadCar",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_LoadingCarInfo_TypeNumberInfo_TypeNumberInfoId",
                        column: x => x.TypeNumberInfoId,
                        principalTable: "TypeNumberInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                });

            migrationBuilder.CreateTable(
                name: "DistributionInfoDetails",
                columns: table => new
                {
                    Id = table.Column<Guid>(nullable: false),
                    Backboxcount = table.Column<int>(nullable: false),
                    Backnumbercount = table.Column<int>(nullable: false),
                    CreationTime = table.Column<DateTime>(nullable: false),
                    CreatorUserId = table.Column<long>(nullable: true),
                    Damagecount = table.Column<int>(nullable: false),
                    DeleterUserId = table.Column<long>(nullable: true),
                    DeletionTime = table.Column<DateTime>(nullable: true),
                    DistributionInfoId = table.Column<Guid>(nullable: true),
                    Distributioncount = table.Column<int>(nullable: false),
                    Exchangegoodscount = table.Column<int>(nullable: false),
                    Givecount = table.Column<int>(nullable: false),
                    IsDeleted = table.Column<bool>(nullable: false),
                    LastModificationTime = table.Column<DateTime>(nullable: true),
                    LastModifierUserId = table.Column<long>(nullable: true),
                    PricesId = table.Column<Guid>(nullable: false),
                    Pricestatus = table.Column<int>(nullable: false),
                    Recoverycount = table.Column<int>(nullable: false),
                    RestaurantTypenNumberInfo = table.Column<Guid>(nullable: false),
                    RestaurantTypenNumberInfoId = table.Column<Guid>(nullable: false),
                    Restaurantid = table.Column<Guid>(nullable: false),
                    Sumprice = table.Column<decimal>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DistributionInfoDetails", x => x.Id);
                    table.ForeignKey(
                        name: "FK_DistributionInfoDetails_DistributionInfo_DistributionInfoId",
                        column: x => x.DistributionInfoId,
                        principalTable: "DistributionInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Restrict);
                    table.ForeignKey(
                        name: "FK_DistributionInfoDetails_RestaurantTypenNumberInfo_RestaurantTypenNumberInfo",
                        column: x => x.RestaurantTypenNumberInfo,
                        principalTable: "RestaurantTypenNumberInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_DistributionInfoDetails_RestaurantInfo_Restaurantid",
                        column: x => x.Restaurantid,
                        principalTable: "RestaurantInfo",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_AbpUsers_FactoryinfoId",
                table: "AbpUsers",
                column: "FactoryinfoId");

            migrationBuilder.CreateIndex(
                name: "IX_CarInfo_EmployeeCarUserId",
                table: "CarInfo",
                column: "EmployeeCarUserId");

            migrationBuilder.CreateIndex(
                name: "IX_DistributionInfo_Carinfoid",
                table: "DistributionInfo",
                column: "Carinfoid");

            migrationBuilder.CreateIndex(
                name: "IX_DistributionInfo_LoadCarId",
                table: "DistributionInfo",
                column: "LoadCarId");

            migrationBuilder.CreateIndex(
                name: "IX_DistributionInfo_Restaurantid",
                table: "DistributionInfo",
                column: "Restaurantid");

            migrationBuilder.CreateIndex(
                name: "IX_DistributionInfoDetails_DistributionInfoId",
                table: "DistributionInfoDetails",
                column: "DistributionInfoId");

            migrationBuilder.CreateIndex(
                name: "IX_DistributionInfoDetails_RestaurantTypenNumberInfo",
                table: "DistributionInfoDetails",
                column: "RestaurantTypenNumberInfo");

            migrationBuilder.CreateIndex(
                name: "IX_DistributionInfoDetails_Restaurantid",
                table: "DistributionInfoDetails",
                column: "Restaurantid");

            migrationBuilder.CreateIndex(
                name: "IX_LoadCar_CarInfoId",
                table: "LoadCar",
                column: "CarInfoId");

            migrationBuilder.CreateIndex(
                name: "IX_LoadingCarInfo_LoadCarId",
                table: "LoadingCarInfo",
                column: "LoadCarId");

            migrationBuilder.CreateIndex(
                name: "IX_LoadingCarInfo_TypeNumberInfoId",
                table: "LoadingCarInfo",
                column: "TypeNumberInfoId");

            migrationBuilder.CreateIndex(
                name: "IX_RestaurantInfo_EmployeeDriverid",
                table: "RestaurantInfo",
                column: "EmployeeDriverid");

            migrationBuilder.CreateIndex(
                name: "IX_RestaurantTypenNumberInfo_Restaurantid",
                table: "RestaurantTypenNumberInfo",
                column: "Restaurantid");

            migrationBuilder.CreateIndex(
                name: "IX_RestaurantTypenNumberInfo_TypeNumberId",
                table: "RestaurantTypenNumberInfo",
                column: "TypeNumberId");

            migrationBuilder.CreateIndex(
                name: "IX_SettlementInfo_EmployeeDriverid",
                table: "SettlementInfo",
                column: "EmployeeDriverid");

            migrationBuilder.CreateIndex(
                name: "IX_SettlementInfo_Restaurantid",
                table: "SettlementInfo",
                column: "Restaurantid");

            migrationBuilder.AddForeignKey(
                name: "FK_AbpUsers_FactoryNameInfo_FactoryinfoId",
                table: "AbpUsers",
                column: "FactoryinfoId",
                principalTable: "FactoryNameInfo",
                principalColumn: "Id",
                onDelete: ReferentialAction.Cascade);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_AbpUsers_FactoryNameInfo_FactoryinfoId",
                table: "AbpUsers");

            migrationBuilder.DropTable(
                name: "DistributionInfoDetails");

            migrationBuilder.DropTable(
                name: "FactoryNameInfo");

            migrationBuilder.DropTable(
                name: "LoadingCarInfo");

            migrationBuilder.DropTable(
                name: "RestaurantUserInfo");

            migrationBuilder.DropTable(
                name: "SettlementInfo");

            migrationBuilder.DropTable(
                name: "DistributionInfo");

            migrationBuilder.DropTable(
                name: "RestaurantTypenNumberInfo");

            migrationBuilder.DropTable(
                name: "LoadCar");

            migrationBuilder.DropTable(
                name: "RestaurantInfo");

            migrationBuilder.DropTable(
                name: "TypeNumberInfo");

            migrationBuilder.DropTable(
                name: "CarInfo");

            migrationBuilder.DropIndex(
                name: "IX_AbpUsers_FactoryinfoId",
                table: "AbpUsers");

            migrationBuilder.DropColumn(
                name: "EmployeeType",
                table: "AbpUsers");

            migrationBuilder.DropColumn(
                name: "Face",
                table: "AbpUsers");

            migrationBuilder.DropColumn(
                name: "FactoryinfoId",
                table: "AbpUsers");

            migrationBuilder.DropColumn(
                name: "Mobile",
                table: "AbpUsers");

            migrationBuilder.DropColumn(
                name: "NowAddress",
                table: "AbpUsers");

            migrationBuilder.DropColumn(
                name: "OpenId_Code",
                table: "AbpUsers");

            migrationBuilder.DropColumn(
                name: "OpenId_Public",
                table: "AbpUsers");

            migrationBuilder.DropColumn(
                name: "Unionid",
                table: "AbpUsers");
        }
    }
}
